Skip to content

fix(cloudflare): 301 docs URLs removed by #383 and #1001 to their new pages - #1336

Merged
twosugar merged 3 commits into
longbridge:mainfrom
nic75408:fix/seo-docs-gone-redirects
Nov 19, 2026
Merged

twosugar merged 3 commits into
longbridge:mainfrom
nic75408:fix/seo-docs-gone-redirects

Conversation

@nic75408

@nic75408 nic75408 commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Two docs reorganisations left old URLs returning 404 with no redirect:

Google Search Console (2026-10-20 ~ 11-17) still shows 6 of these URLs with 295 impressions (/docs/how-to-access-api avg. position 3.4, /docs/error-codes 6.5). Developers following search results, AI tools or old links land on the 404 page.

This PR adds 17 entries to the existing GONE_PAGES table in functions/[[path]].ts (the #1317 mechanism). resolveGone() carries the locale prefix and the .md twin, so the 17 entries cover 51 page URLs (17 × en / zh-CN / zh-HK) plus their .md twins. One file. The only logic change is that resolveGone() now accepts a target with its own query string (needed for error-codes, how-to-access-api and refresh-token-api, see below); entries without a query behave exactly as before.

Old path (all 3 locales, page and .md) 301 to Why
/docs/how-to-access-api /docs/api?page=authentication (.md → /docs/api.md) merged into x-pages.authentication by #383
/docs/refresh-token-api /docs/api?page=authentication (.md → /docs/api.md) merged into x-pages.authentication by #383
/docs/error-codes /docs/api?page=error-codes (.md → /docs/api.md) merged into x-pages.error-codes by #383; same address as in-site error code links (see below)
/docs/quote/pull/trade-session /docs/market/trade-session renamed by #1001
/docs/quote/pull/trade-day /docs/market/trade-days renamed by #1001
/docs/quote/pull/market_temperature /docs/market/market-temperature renamed by #1001
/docs/quote/pull/history_market_temperature /docs/market/history-market-temperature renamed by #1001
/docs/fundamental/market/market-status /docs/market/market-status renamed by #1001
/docs/fundamental/market/unusual-items /docs/market/unusual-items renamed by #1001
/docs/fundamental/calendar/dividend-calendar /docs/market/calendar/dividend-calendar renamed by #1001
/docs/fundamental/calendar/earnings-calendar /docs/market/calendar/earnings-calendar renamed by #1001
/docs/fundamental/calendar/ipo-calendar /docs/market/calendar/ipo-calendar renamed by #1001
/docs/fundamental/calendar/macro-calendar /docs/market/calendar/macro-calendar renamed by #1001
/docs/fundamental/calendar/meeting-calendar /docs/market/calendar/meeting-calendar renamed by #1001
/docs/fundamental/calendar/merge-calendar /docs/market/calendar/merge-calendar renamed by #1001
/docs/fundamental/calendar/split-calendar /docs/market/calendar/split-calendar renamed by #1001
/docs/content/news /docs/content/news/news category folder has no landing page; only news/news is in the sitemap

Targets with a query (error-codes, how-to-access-api, refresh-token-api)

/docs/api without a query lands on Overview (resolvePage() in packages/api-reference/src/ApiReference.tsx defaults to overview), so these three go to the view that holds their content: /docs/error-codes → /docs/api?page=error-codes (the address in-site error code links use), /docs/how-to-access-api and /docs/refresh-token-api → /docs/api?page=authentication (suggested in review). resolveGone() now splits a target into path and query:

Request Location
/docs/error-codes /docs/api?page=error-codes
/zh-HK/docs/error-codes?x=1 /zh-HK/docs/api?page=error-codes&x=1 (target query first, incoming query appended)
/zh-CN/docs/error-codes.md /zh-CN/docs/api.md
/en/docs/error-codes.md?x=1 /docs/api.md?x=1
/docs/how-to-access-api /docs/api?page=authentication
/zh-CN/docs/refresh-token-api?x=1 /zh-CN/docs/api?page=authentication&x=1
/zh-HK/docs/how-to-access-api.md /zh-HK/docs/api.md

For .md requests the .md suffix goes on the path and the target query is dropped, so it never becomes ?page=error-codes.md. ?page= only switches the view in the browser; the markdown twin /docs/api.md is the whole API Reference and already contains the error code table and the authentication section (checked in production: /docs/api.md, /zh-CN/docs/api.md, /zh-HK/docs/api.md are 200 and include 403201 and X-Api-Signature; /docs/api/error-codes(.md) is 404; /docs/api?page=authentication is 200 in all 3 locales and authentication is an x-pages id in openapi.yaml). The incoming query is kept in both cases, as before.

Verification (before merge)

  • Production today (2026-11-19): all 51 old page URLs return 404; all 90 target URLs (15 targets × 3 locales × page/.md) return 200; /docs/api?page=error-codes and /docs/api?page=authentication are 200 in all 3 locales.
  • Called onRequest locally for each of the 17 paths × (root, /en, /zh-CN, /zh-HK) × (page, .md) × (no query, ?a=1): 272/272 return 301 with the expected Location (/en dropped, incoming query kept; error-codes pages → ?page=error-codes, how-to-access-api / refresh-token-api pages → ?page=authentication, their .md → api.md). Re-run on 2b748fe after the review change: 272/272. Existing entries and current pages unaffected (us_etf_files and us_etf_files.md?q=2 still 301 as before, /docs/market/trade-session, /docs/api, /docs/content/news/news pass through).
  • vitest run: 60/60 passed. tsc --noEmit --strict and oxlint on the file: clean. (prettier -c reports two pre-existing long lines on main, not in this diff.)
  • No build was run, per CLAUDE.md.

Post-deploy check

Request each of the 17 old paths in en, zh-CN and zh-HK once (51 URLs):

  • expect 301, Location matching the table (zh-CN / zh-HK keep their prefix, en has none)
  • the Location target returns 200
  • error-codes, how-to-access-api, refresh-token-api also in .md for all 3 locales: error-codes page → …/docs/api?page=error-codes, the other two pages → …/docs/api?page=authentication, all .md → …/docs/api.md

Sample: curl -sI https://open.longbridge.com/docs/how-to-access-api → 301, location: https://open.longbridge.com/docs/api?page=authentication.

🤖 Generated with Claude Code

zhiqiangni-lb and others added 2 commits November 19, 2026 14:31
…ge#1001 to their new pages

Add 17 entries to GONE_PAGES so the old Overview / Refresh Token / Error
Codes pages (merged into /docs/api by longbridge#383), the market endpoints moved by
longbridge#1001, and the /docs/content/news category redirect instead of 404.
resolveGone() carries the locale prefix and .md twin, covering 51 page URLs
plus their markdown twins.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Per review, /docs/error-codes now 301s to /docs/api?page=error-codes, the
address used by in-site error code links. resolveGone() accepts a target
with its own query: page requests get the target query first and the
incoming query appended; .md requests drop the target query and go to the
markdown twin (/docs/api.md, which already contains the error code
table), so they never become ?page=error-codes.md.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@twosugar

Copy link
Copy Markdown
Collaborator

Reviewed, looks good to merge. One suggestion before merging:

/docs/how-to-access-api and /docs/refresh-token-api both go to /docs/api, but /docs/api with no query lands on the Overview page (resolvePage() in packages/api-reference/src/ApiReference.tsx defaults to overview). As the PR description says, their content was merged into x-pages.authentication, so following the same approach as error-codes, /docs/api?page=authentication would land users on the right page. The .md twins would still go to /docs/api.md via your new query handling.

Checked locally by calling onRequest on the PR head: error-codes page / .md / with query, /en prefix, content/news.md, an existing entry (us_asset_overview.md?q=2) and a live page (/docs/content/news/news) all behave as described.

Will merge once this is updated.

拉罐的 Claude 代发

…authentication view

/docs/api without a query lands on Overview (resolvePage() defaults to
overview). Both pages were merged into x-pages.authentication by longbridge#383, so
point them at /docs/api?page=authentication, the same way error-codes
goes to ?page=error-codes. The .md twins still go to /docs/api.md.

Suggested in review by @twosugar.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@nic75408

Copy link
Copy Markdown
Contributor Author

/docs/how-to-access-api and /docs/refresh-token-api both go to /docs/api … /docs/api?page=authentication would land users on the right page.

Thanks, updated in 2b748fe (one commit on top, no force push): both now 301 to /docs/api?page=authentication, .md twins still go to /docs/api.md. PR description table and post-deploy check updated.

Re-ran onRequest locally for all 17 entries × (root, /en, /zh-CN, /zh-HK) × (page, .md) × (no query, ?a=1): 272/272 return 301 with the expected Location. The two changed entries:

Request Status Location
/docs/how-to-access-api 301 /docs/api?page=authentication
/en/docs/how-to-access-api?a=1 301 /docs/api?page=authentication&a=1
/zh-CN/docs/how-to-access-api 301 /zh-CN/docs/api?page=authentication
/zh-HK/docs/how-to-access-api.md 301 /zh-HK/docs/api.md
/docs/refresh-token-api.md?a=1 301 /docs/api.md?a=1
/zh-CN/docs/refresh-token-api?a=1 301 /zh-CN/docs/api?page=authentication&a=1
/zh-HK/docs/refresh-token-api 301 /zh-HK/docs/api?page=authentication
/en/docs/refresh-token-api.md 301 /docs/api.md

(all 32 combinations of these two paths pass; the rows above are a sample.) /docs/api, /docs/api.md, /zh-CN/docs/api?page=authentication, /docs/market/trade-session, /docs/content/news/news still pass through; us_etf_files and us_etf_files.md?q=2 unchanged.

Target check in production: /docs/api?page=authentication is 200 in en / zh-CN / zh-HK, and authentication is an x-pages id in openapi.yaml, so resolvePage() selects it. /docs/api.md in all 3 locales contains the authentication section (X-Api-Signature).

vitest run 60/60, tsc --noEmit --strict --skipLibCheck and oxlint on the file clean; prettier -c only reports the two long lines already on main.

赤拔的 Claude 代发

@twosugar
twosugar merged commit b20183b into longbridge:main Nov 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants